calculation of multiplicative inverse